<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ include file="/common/taglibs.jsp" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>系统管理</title>
    <link href="${cdnctx}/dep/jquery/jquery-ui-1.10.2.custom.css" rel="stylesheet" type="text/css"/>
    <%@ include file="/common/util.jsp" %>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#addCollectAreaForm").validate({
                rules: {
                    'customerinfoid': {
                        required: true
                    },
                    'areacode': {
//                        required: true,
                        digits: true,
                        maxlength: 10
                    },
                    'areaname': {
                        required: true
                    }
                },
                messages: {
                    'customerinfoid': {
                        required: "公司名称"
                    },
                    'areacode': {
//                        required: "区域番号",
//                        digits: "请输入合法的ID格式",
                        maxlength: $.validator.format("请输入不超过{0}位数的区域番号")
                    },
                    'areaname': {
                        required: "区域名称"
                    }
                },
                submitHandler: function (form) {
                    var customerArea = {
                        "id": $('#id').val(),
                        "customerinfoid": $('#customerinfoid').val(),
                        "areaname": $('#areaname').val()
                    };

                    $.ajax({
                        contentType: "application/json",
                        url: "${cdnctx}/systemCustomerArea/existcustomerArea.shtml",
                        data: customerArea,
                        async: false,
                        dataType: "json",
                        success: function (data) {
                            var flag = data.existFlag;
                            if (flag)
                                form.submit();
                            else {
                                $('#customerAreaExist').show();
                                $('#customerAreaExist').delay(3000).hide(0);
                            }
                        }
                    });
                }
            });
        });
    </script>
</head>
<body class="main">
<div class="-frame -style -luster" id="css_container">
    <!--首页框架页眉部分↓-->
    <%@ include file="/WEB-INF/pages/inc/header.jsp" %>
    <!--首页框架页眉部分↑-->

    <div class="content">

        <!-- Left导航菜单◎开始 -->
        <%@ include file="/WEB-INF/pages/inc/leftmenu.jsp" %>
        <!-- Left导航菜单◎结束 -->

        <div class="main-mid">
            <div class="pos"><img src="${cdnctx}/src/index/img/index.png"><a
                    href="<%--${cdnctx}/system/systemMenu.shtml--%>">系统管理 </a>
                ><a href="${cdnctx}/system/customerinfo/customerMain.shtml">公司信息管理</a>
                ><a href="${cdnctx}/systemCustomerArea/customerAreaList.shtml?customerinfoid=${customerinfoid}">${companyname }</a>
                ><a><c:if test="${empty customerArea }">添加</c:if><c:if
                        test="${not empty customerArea }">编辑</c:if>采集区域</a></div>

            <div class="css_contentDiv">
                <div class="searchDetailed">
                    <form id="addCollectAreaForm" method="post"
                          action="${cdnctx}/systemCustomerArea/customerAreaSave.shtml">
                        <input type="hidden" name="id" id="id" value="${customerArea.id}"/>
                        <table align="center" id="table" width="800" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td class="mainText"><label class="formlabel"><font color="red">*</font>所属公司：</label>
                                </td>
                                <td>
                                    <input type="hidden" id="customerinfoid" name="customerinfoid"
                                           value='${customerinfoid}'>
                                    <span>${companyname}</span>
                                </td>
                            </tr>
                            <tr>
                                <td class="mainText"><label class="formlabel">区域番号：</label>
                                </td>
                                <td>
                                    <input type="text" class="form_input large" name="areacode" id="areacode"
                                           value="${customerArea.areacode}"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="mainText"><label class="formlabel"><font color="red">*</font>区域名称：</label>
                                </td>
                                <td>
                                    <input type="text" class="form_input large" name="areaname" id="areaname"
                                           value="${customerArea.areaname}" maxlength="40"/>
                                    <span id="customerAreaExist" style="display: none; color: #b92c28">该区域已存在</span>

                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <input type="submit" class="form_save" value="保&nbsp;存"/>
                                    <input type="reset" class="form_cancle" value="取&nbsp;消"/>
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>
        </div>

    </div>

    <!--首页框架页尾部分↓-->
    <%@ include file="/WEB-INF/pages/inc/footer.jsp" %>
    <!--首页框架页尾部分↑-->
</div>
</body>
</html>